package com.exam.sacrifice.ui.login;

import android.view.View;

import com.exam.commonbiz.base.BaseActivity;
import com.exam.commonbiz.util.OnFastClickListener;
import com.exam.commonbiz.util.ToastUtil;
import com.exam.sacrifice.R;
import com.exam.sacrifice.databinding.ActivityLoginBinding;
import com.exam.sacrifice.ui.MainActivity;
import com.exam.sacrifice.ui.RegisterActivity;
import com.exam.sacrifice.util.AESUtil;
import com.exam.sacrifice.viewmodel.ILoginCallBack;
import com.exam.sacrifice.viewmodel.LoginViewModel;

public class LoginActivity extends BaseActivity<LoginViewModel, ActivityLoginBinding> implements ILoginCallBack {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    public void initData() {

        mViewModel.setLoginCallBack(this);
        binding.btnLogin.setOnClickListener(new OnFastClickListener() {
            @Override
            public void onFastClick(View v) {
                actionStart(MainActivity.class);
                finish();
            }
        });

        binding.btnLogin.setOnClickListener(new OnFastClickListener() {
            @Override
            public void onFastClick(View v) {

                String phone = "18721412241";
                String password = "fete2241";
                mViewModel.login(phone, password);
            }
        });

        binding.btnRegister.setOnClickListener(new OnFastClickListener() {
            @Override
            public void onFastClick(View v) {
                actionStart(RegisterActivity.class);
            }
        });

        binding.edtPhone.setText("18888888888");
        binding.edtPsd.setText("123456");
    }

    @Override
    public void onLoginCallBack() {
        ToastUtil.getInstance().showToast("登录成功");
        actionStart(MainActivity.class);
        finish();
    }
}